<template>
  <div>
    <div id="wolf-map"></div>
    <router-view/>
    <i class="iconfont icon-move wolf-move" @click="localPosition"></i>
    <div class="operator-list">
      <div class="operator-button" :class="operatorIndex===0?'active':''"
           @click="routerPush('/',0)">
        <i class="iconfont icon-dingwei"></i>
        <div class="name">定位</div>
      </div>
      <div class="operator-button" :class="operatorIndex===1?'active':''"
           @click="routerPush('/navigation',1)">
        <i class="iconfont icon-navigation"></i>
        <div class="name">导航</div>
      </div>
      <div class="operator-button" :class="operatorIndex===2?'active':''"
           @click="routerPush('/retrieve',2)">
        <i class="iconfont icon-discount"></i>
        <div class="name">检索</div>
      </div>
      <div class="operator-button" :class="operatorIndex===3?'active':''"
           @click="routerPush('/visualization',3)">
        <i class="iconfont icon-data-view"></i>
        <div class="name">可视化</div>
      </div>
    </div>
  </div>
</template>

<script>
import {mapActions, mapState} from "vuex";

export default {
  name: "Index",
  methods: {
    ...mapActions(["localPosition", "setOperatorIndex"]),
    routerPush(target, index) {
      this.setOperatorIndex(index)
      if (this.$route.path !== target) {
        this.$router.push(target)
      }
    }
  },
  computed: {
    ...mapState(["operatorIndex"])
  }
}
</script>

<style scoped lang="less">
#wolf-map {
  width: 100vw;
  height: 100vh;
}

.wolf-search {
  width: 97%;
  height: auto;
  left: 50%;
  top: 15px;
  transform: translateX(-50%);
  position: fixed;
  z-index: 999;
  box-sizing: border-box;
  padding: 0 10px 0 10px;
  background-color: #fff;
  border-radius: 10px;
  font-size: 14px;

  .search-input {
    width: 100%;
    height: 45px;
  }

  .search-suggestion {
    transition: 1s height;

    .suggestion-one {
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;

      .address-info {
        padding: 5px 0;
        display: flex;
        align-content: center;
        flex-flow: column;
        font-size: 12px;
        width: 95%;

        .name {
          color: black;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          max-width: 85%;
        }

        .address {
          margin-top: 5px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          color: rgba(100, 100, 100);
          max-width: 85%;
        }
      }

    }
  }
}


.wolf-search-button {
  z-index: 9999;
  top: 0;
  left: 0;
  font-size: 25px;
  background-color: black;
  position: absolute;
}

.operator-list {
  width: 100%;
  height: 45px;
  bottom: 0;
  position: absolute;
  z-index: 99999;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  background-color: rgb(250, 250, 250);
  box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);

  .operator-button {
    width: 25%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-flow: column;
    box-sizing: border-box;
    padding: 5px;
    color: rgba(0, 0, 0, .5);

    .iconfont {
      font-weight: bold;
      font-size: 21px;
    }

    .name {
      font-size: 12px;
    }
  }

  .active {
    color: green;
  }
}

.wolf-move {
  bottom: 55px;
  right: 10px;
  position: absolute;
  font-size: 25px;
  padding: 5px;
  color: rgba(0, 0, 0, .8);
  background-color: white;
  border-radius: 10px;
  z-index: 999;
  box-shadow: rgba(0, 0, 0, .2) 0 0 5px;
}
</style>